#include<iostream>
#include<signal.h>
#include<unistd.h>
#include<cstdio>
using namespace std;


void Count(int cnt)
{
    while(cnt)
    {
        printf("cnt: %2d\r",cnt);
        fflush(stdout);
        cnt--;
        sleep(1);
    }
    cout<<endl;
}
void handler(int signo)
{
    cout<<"get a signo: "<<signo<<"正在处理中..."<<endl;
    Count(20);
}
void test()
{
    struct sigaction act,oact;
    act.sa_handler = handler;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,3);
    sigaction(SIGINT,&act,&oact);
    while(true) sleep(1);
}
int main()
{
    test();
    return 0;
}